package org.personal.entity;

import org.myhibernate.annotation.MapProperty;
import org.myhibernate.annotation.MapProperty.MapType;
import org.myhibernate.id.NumberID;
import org.personal.Constants;

import com.util.ConfigUtil;
import com.util.IOUtil;

public class Layout 
{
	private int id=-1;
	private String pagePath="";
	private String title="";
	@MapProperty(map=MapType.FALSE)
	private String html="";
	private String image="";
	private boolean defaultLayout=false;
	
	public int getId() {
		if (id == -1)
		{
			id=NumberID.getId(Layout.class).intValue();
		}
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getPagePath() {
		return pagePath;
	}
	public void setPagePath(String pagePath) {
		this.pagePath = pagePath;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getHtml() {
		return html;
	}
	public void setHtml(String html) {
		this.html = html;
	}
	public String getImage() {
		return image;
	}
	public void setImage(String image) {
		this.image = image;
	}
	public boolean getDefaultLayout() {
		return defaultLayout;
	}
	public void setDefaultLayout(boolean defaultLayout) {
		this.defaultLayout = defaultLayout;
	}
	
	public void reload()
	{
		String baseProjectPath=ConfigUtil.getAttribute(Constants.CONTEXT);
		IOUtil ioUtil=new IOUtil();
		String layoutHtml=ioUtil.read(baseProjectPath+getPagePath(), "utf-8", "");
		setHtml(layoutHtml);
	}
	
}
